<style>
.item_s{height:30px;line-height:30px;}
</style>

   
   
   
   <section class="topBanners">
         <div class="icon"></div>
         <div class="topBannersNav">
         <span data-url="/admin/group/lists"  onclick="ContentLoadGo('/admin/group/lists')">角色管理</span> >
         <span data-url="/admin/group/power1" data-param-id="<?php echo $info['id'] ?>" data-container="rt_content" class="topBannerItem">权限管理</span>
         </div>
      </section>
     
 
   <section id="zc_detail">

      
     
      <div style="height:50px;line-height:50px;text-align:center;font-size:20px;font-weight:800"><?php echo $info['gname']; ?></div>
      

     
        <div style="width:90%;text-align:left;font-size:14px;margin:10px auto;">
            
               <?php
                  foreach($ruleobjLists as $key=>$val)
                  {
                     ?>
                     <div style="width:33%;float:left;min-height:200px;">
                     <div class="item_s">-<input type="checkbox" class="powerItem <?php echo $val['id'];?>" id="<?php echo $val['id'];?>" mydata="<?php echo $val['id'];?>" name="powerItem[]" value="<?php echo $val['id'];?>" <?php if(in_array($val['id'],$tempRule)){echo 'checked';} ?> ><?php echo $val['oname'];?></div>
                     <?php
                     foreach($val['child'] as $k2=>$v2)
					 {
                     ?>
                      
                     	<div style="padding-left:10px;" class="item_s">-<input type="checkbox" class="powerItem <?php echo $val['id'];?>_<?php echo $v2['id'];?>" mydata="<?php echo $val['id'];?>_<?php echo $v2['id'];?>" id="<?php echo $val['id'];?>_<?php echo $v2['id'];?>" name="powerItem[]" value="<?php echo $v2['id'];?>" <?php if(in_array($v2['id'],$tempRule)){echo 'checked';} ?> ><?php echo $v2['oname'];?></div>
                     <?php
                        foreach($v2['child'] as $k3=>$v3)
						{
                        ?>
                        <div style="padding-left:20px;" class="item_s">-<input type="checkbox" class="powerItem <?php echo $val['id'];?>_<?php echo $v2['id'];?>_<?php echo $v3['id'];?>" mydata="<?php echo $val['id'];?>_<?php echo $v2['id'];?>_<?php echo $v3['id'];?>" id="<?php echo $val['id'];?>_<?php echo $v2['id'];?>_<?php echo $v3['id'];?>" name="powerItem[]" value="<?php echo $v3['id'];?>" <?php if(in_array($v3['id'],$tempRule)){echo 'checked';} ?> ><?php echo $v3['oname'];?></div>
                        <?php
						}
					?>
				
					
					<?php
					 }
					?>
					</div>
					<?php
				  }
               ?>
               <br style="clear:both;width:0px; height:0px;" />
          </div>
      
      <ul class="ulColumn2">
      
      
       <li style="text-align:center">
        <input type="hidden" name="depthID" id="depthID" value="<?php echo $info['id'] ?>">
        <input type="button" value="设置" class="link_btn set_power"/>
        
       </li>
      </ul>
     </section>

      <script type="text/javascript">
      
      function myResearch(){
		   var url="/admin/group/power1";
		   var id =$("#depthID").val();
		  
		   var param={
				  id:id
		   };
		   ContentGet(url,param);
	   }
     
      
           $(function(){
        	   //设置搜索栏
        	   $(".research").click(function(){
        		   
        		   myResearch();
        		   
        	   });
        	   
        	  
        	 
        	   //
        	   $('.set_power').click(function(){
        		   var that =this;
        		   var url="/admin/group/set_power";
        		   var id=$("#depthID").val();
        		   var power=getAllSelectItemPower();
        		   
        		   var param={
        				   id:id,
        				   power:power
        		   };
        		   cofirmsss_tishi(1,'您确定要执行该操作吗？',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            			
            				   
            				  
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });
        	
        	   
        	   
        	   //导航
        	   $(".topBannerItem").click(function(){
        		   
        		   var attArr = $(this).attr();
            	   goToSelfLink(attArr);
            	   
        			
        	   });
  			   //全选
  		
  				$(".powerItem").click(function(){  
  					var data=$(this).attr("mydata");
  					dataArr=data.split("_");
  					//console.log(dataArr);
			    	if(this.checked){   
			    		var cs="";
			    		
			    		for(var i=0;i<dataArr.length;i++)
			    			{
			    			   if(cs=="")
			    			   {
			    				   cs=dataArr[i];
			    			   }else
			    			   {
			    				   cs=cs+"_"+dataArr[i];
			    			   }
			    			   $("#"+cs).attr("checked", true);
			    			   $("#"+cs).prop("checked", true);
			    			   
			    			}
			        	//$(this).parent().prev().children(".powerItem").attr("checked", true);  
			        	//$(this).parent().prev().children(".powerItem").prop("checked", true); 
			        	//$(this).parent().parent().children(".item_s:first-child").children(".powerItem:first-child").attr("checked", true);  
			        	//$(this).parent().parent().children(".item_s:first-child").children(".powerItem:first-child").prop("checked", true); 
			    	}else{  
			    		
			    		$('input[id*='+data+']').attr("checked", false);
			    		$('input[id*='+data+']').prop("checked", false);
			    		//$(this).parent().prev().children(".powerItem").attr("checked", true);  
			        	//$(this).parent().prev().children(".powerItem").prop("checked", true); 
			        	//$(this).parent().parent().children(".item_s:first-child").children(".powerItem:first-child").attr("checked", true);  
			        	//$(this).parent().parent().children(".item_s:first-child").children(".powerItem:first-child").prop("checked", true); 
			    	}   
			    	var se=getAllSelectItem();
			    	//console.log(se);
			 	}); 
  			   
  			
           });
           
           function getAllSelectItemPower()
           {
           	      var str="";
           	      $("input[name='powerItem[]']:checked").each(function(){
           	    	  if(str=="")
           	    		  {
           	    		str+=$(this).val();
           	    		  }
           	    	  else
           	    		  {
           	    		str+=","+$(this).val();
           	    		  }
           	    	  		
           	    	  });
           	      return str;
           }
           
	  </script>
   